package com.ruoyi.web.controller.customer;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.api.domain.VAppDetail;
import com.ruoyi.api.service.IVAppDetailService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 应用详情视图Controller (Customer权限)
 * 
 * @author ruoyi
 * @date 2025-01-15
 */
@RestController
@RequestMapping("/customer/vAppDetail")
@PreAuthorize("@ss.hasRole('customer')")
public class CustomerVAppDetailController extends BaseController
{
    @Autowired
    private IVAppDetailService vAppDetailService;

    /**
     * 查询应用详情视图列表
     */
    @GetMapping("/list")
    public TableDataInfo list(VAppDetail vAppDetail)
    {
        startPage();
        vAppDetail.setAppUser(getUsername());
        List<VAppDetail> list = vAppDetailService.selectVAppDetailList(vAppDetail);
        return getDataTable(list);
    }

    /**
     * 导出应用详情视图列表
     */
    @Log(title = "应用详情视图", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, VAppDetail vAppDetail)
    {
        List<VAppDetail> list = vAppDetailService.selectVAppDetailList(vAppDetail);
        ExcelUtil<VAppDetail> util = new ExcelUtil<VAppDetail>(VAppDetail.class);
        util.exportExcel(response, list, "应用详情视图数据");
    }

    /**
     * 获取应用详情视图详细信息
     */
    @GetMapping(value = "/{appId}")
    public AjaxResult getInfo(@PathVariable("appId") Long appId)
    {
        return success(vAppDetailService.selectVAppDetailByAppId(appId));
    }
}